package com.snow.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.snow.service.RabbitmqService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description:
 * @Author: 爱飘de小子
 * @CreateDate: 2018/8/17 23:33
 * @Version: 1.0
 */
@Service(version="1.0.0", application="${dubbo.application.id}", protocol="${dubbo.protocol.id}", registry="${dubbo.registry.id}")
public class RabbitmqServiceImpl implements RabbitmqService {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    @Override
    public String sendMessage(String message) {
        this.rabbitTemplate.convertAndSend("hello", message);
        return "success";
    }


    /**
     * 消息接受
     * @param message
     */
    @RabbitListener(queues = "hello")  //监听器监听指定的Queue
    public void receive(String message) {
        System.out.println("接收消息:" + message);
    }


    /**
     * 消息接受  并发消费
     * @param message
     */
//    @RabbitListener(queues = "hello",containerFactory = "pointTaskContainerFactory")
//    public void receive(String message) {
//        System.out.println("接收消息:" + message);
//    }







}
